{ "cells": [ { "cell_type": "markdown", "id": "94299699-3b41-4149-a870-db571ffd944c", "metadata": {}, "source": [ "# Copy Number Variation" ] }, { "cell_type": "code", "execution_count": null, "id": "88be5cea-2412-41f3-bd2c-8447fb7616a7", "metadata": {}, "outputs": [], "source": [ "from pylluminator.samples import Samples\n", "from pylluminator.cnv import copy_number_variation\n", "from pylluminator.utils import load_object, save_object, set_logger\n", "from pylluminator.visualizations import manhattan_plot_cnv\n", "\n", "set_logger('WARNING') # set the verbosity level, can be DEBUG, INFO, WARNING, ERROR" ] }, { "cell_type": "markdown", "id": "1370e2cc-bb01-40c4-828f-98df3dabc7f2", "metadata": {}, "source": [ "## Load pylluminator Samples\n", "\n", "We assume that you have already processed the .idat files according to your preferences and saved them. If not, please refer to notebook `1 - Read data and get beta values` before going any further." ] }, { "cell_type": "code", "execution_count": null, "id": "0988935f-7779-46e0-b546-145c0652bcdc", "metadata": {}, "outputs": [], "source": [ "my_samples = Samples.load('preprocessed_samples')\n", "my_samples" ] }, { "cell_type": "code", "execution_count": null, "id": "b63ff882-d0a4-421a-83c4-8f4131f784f3", "metadata": {}, "outputs": [], "source": [ "sample_sheet = my_samples.sample_sheet\n", "sample_sheet" ] }, { "cell_type": "markdown", "id": "5868c013-7901-46e1-8504-e9dc9c33590f", "metadata": {}, "source": [ "## Get CNVs for a sample" ] }, { "cell_type": "code", "execution_count": null, "id": "33992775-4ff4-41b3-8adc-749d93e01bc0", "metadata": {}, "outputs": [], "source": [ "name = 'LNCAP_500_1' # sample name\n", "normalization_samples = sample_sheet[sample_sheet.sample_type == 'PREC'].sample_name.values\n", "print('normalization_samples : ', normalization_samples)\n", "\n", "ranges, signal_bins_df, segments_df = copy_number_variation(my_samples, sample_label=name, normalization_sample_labels=normalization_samples)" ] }, { "cell_type": "markdown", "id": "85f5adb1-d7c8-4f87-a21f-71a27dec1b31", "metadata": {}, "source": [ "## Visualize CNVs and segments" ] }, { "cell_type": "markdown", "id": "819b8510-78ba-49f3-8d14-b91606f40b9a", "metadata": {}, "source": [ "Plot the identified segments and CNV values" ] }, { "cell_type": "code", "execution_count": null, "id": "336ccc68-5994-455b-aeb0-d7eb5273c2c1", "metadata": {}, "outputs": [], "source": [ "manhattan_plot_cnv(signal_bins_df, segments_df)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.7" } }, "nbformat": 4, "nbformat_minor": 5 }